function [Az] = EffAz(a0, a1, a2, mu)
%
% Effective Ionisation Level (Az)
%
%DESCRIPTION:
%This function computes the Effective Ionisation Level (Az) at the given
%receiver (RX) location (havging MODIP (mu)) as a function of the
%coefficients broadcated in navigation message (a0,a1,a2).
%
%PROTOTYPE:
% [Az] = EffAz(a0, a1, a2, mu)
%
%--------------------------------------------------------------------------
% INPUTS:
%   a0         [1x1]       1st Coeff.                [-]
%   a1         [1x1]       2nd Coeff.                [-]
%   a2         [1x1]       3rd Coeff.                [-]
%   mu         [1x1]       Modified Dip Latitude     [deg]
%--------------------------------------------------------------------------
% OUTPUTS:
%   Az         [1x1]       Effective Ion. Level      [-]
%--------------------------------------------------------------------------
%
%NOTES:
% - The Effective Ionisation Level (Az) is not updated with MODIP along the
%   ray. Instead, for each ray, Az id fixed to the one corresponding to
%   MODIP at RX location.
% - This parameter is equivalent to F10.7 in climatological NeQuick.
%
%CALLED FUNCTIONS:
% (none)
%
%UPDATES:
% (none)
%
%REFERENCES:
% [1] "Ionospheric Correction Algorithm for Galileo Single-Frequency Users"
%      - European GNSS (Galileo) Open Service
% [2] "Electron Density Models and Data for Transionospheric Radio
%      Propagation" - Report ITU-R P.2297-1 (05/2019)
%
%AUTHOR(s):
%Luigi De Maria, Matteo D'Addazio, 2022
%

%% Main Code

if (a0 == 0) && (a1 == 0) && (a2 == 0)
    Az = 63.7;
else
    Az = a0 + a1*mu + a2*mu^2;
    if (Az < 0) || (Az > 400)
        disp('Effective Ionisation Level (Az) out of boundaries ([0,400])');
        disp('Autocorrection Done!');
        if     Az < 0
            Az = 0.0;
        elseif Az > 400
            Az = 400.0;
        end
    end
end

end